package ua.com.globallogic.basecamp.krasnyanskiy.primenumbers;

import java.util.List;
import java.util.Scanner;

public class MyPrimeNumberTest {
    public static void main(String[] args) {

        /* reads input*/
        int boundary;
        int threads;
        Scanner scanner = new Scanner(System.in);

        System.out.print("Please enter the number of threads " +
                "and the boundary separated by space: ");

        try {
            String str = scanner.nextLine();
            threads = Integer.parseInt(str.split("\\s+")[0]);
            boundary = Integer.parseInt(str.split("\\s+")[1]);
        } catch (Exception e) {
            System.err.println("\nWrong data input: " + e.getMessage());
            return;
        }

        /* calculates all prime numbers less then a given boundary */
        List<Integer> primes =
                new PrimeNumber().
                        buildPrimes(threads, boundary).
                        printNumberOfPrimes().
                        printTime().
                        getResult();

        System.out.println("First prime number is: " + primes.get(0));
    }
}
